package model

import (
	"manager/model/entity"

	"github.com/lib/pq"
)

// FeedbackCreateRequest 创建现场数据
type FeedbackCreateRequest struct {
	UserId int64 `json:"user_id"`

	UserName string `json:"user_name"`

	Phone string `json:"phone"`

	Type int `json:"type"`

	Details string `json:"details"`

	Images pq.StringArray `json:"images"`

	UpdatedAt int64 `json:"updated_at"`
}

// FeedbackUpdateRequest 更新现场数据
type FeedbackUpdateRequest struct {
	Id int64 `json:"id"`

	UserId *int64 `json:"user_id"`

	UserName *string `json:"user_name"`

	Phone *string `json:"phone"`

	Type *int `json:"type"`

	Details *string `json:"details"`

	Images *pq.StringArray `json:"images"`

	CreatedAt int64 `json:"created_at"`

	UpdatedAt *int64 `json:"updated_at"`
}

// FeedbackListRequest 列表现场数据
type FeedbackListRequest struct {
	Index int `json:"index"`
	Size  int `json:"size"`

	Id int64 `json:"id"`

	UserId *int64 `json:"user_id"`

	UserName *string `json:"user_name"`

	Phone *string `json:"phone"`

	Type *int `json:"type"`

	Details *string `json:"details"`

	Images *pq.StringArray `json:"images"`

	UpdatedAt *int64 `json:"updated_at"`

	StartTime *int64 `json:"start_time"`
	EndTime   *int64 `json:"end_time"`

	TimeZone []int64 `json:"time_zone"`

	CreatedAt []int64 `json:"created_at"`
}

// FeedbackListResponse 列表回包数据
type FeedbackListResponse struct {
	Total int             `json:"total"`
	List  []*FeedbackInfo `json:"list"`
}

// FeedbackInfoRequest 列表现场数据
type FeedbackInfoRequest struct {
	Id int64 `json:"id"`

	UserId *int64 `json:"user_id"`

	UserName *string `json:"user_name"`

	Phone *string `json:"phone"`

	Type *int `json:"type"`

	Details *string `json:"details"`

	Images *pq.StringArray `json:"images"`

	UpdatedAt *int64 `json:"updated_at"`
}

// FeedbackInfo 详细数据
type FeedbackInfo struct {
	Id int64 `json:"id"`

	UserId int64 `json:"user_id"`

	UserName string `json:"user_name"`

	Phone string `json:"phone"`

	Type int `json:"type"`

	Details string `json:"details"`

	Images pq.StringArray `json:"images"`

	CreatedAt int64 `json:"created_at"`

	UpdatedAt int64 `json:"updated_at"`
}

// FeedbackDeleteRequest 删除现场数据
type FeedbackDeleteRequest struct {
	Id int64 `json:"id"`
}

// FeedbacksEntityToDto entity数据转换
func FeedbacksEntityToDto(feedbacks []*entity.Feedback) []*FeedbackInfo {
	out := make([]*FeedbackInfo, 0, len(feedbacks))
	for _, c := range feedbacks {
		out = append(out, FeedbackEntityToDto(c))
	}
	return out
}

// FeedbackEntityToDto entity数据转换
func FeedbackEntityToDto(e *entity.Feedback) *FeedbackInfo {
	return &FeedbackInfo{

		Id: e.Id,

		UserId: e.UserId,

		UserName: e.UserName,

		Phone: e.Phone,

		Type: e.Type,

		Details: e.Details,

		Images: e.Images,

		CreatedAt: e.CreatedAt,

		UpdatedAt: e.UpdatedAt,
	}
}
